package day01;

/**
 * @author feng
 * @Date 2021/10/14 11:09
 */
public class DoubleCheck {
    public static void main(String[] args) {
        System.out.println(SingletonTest03.getInstance());
    }
}

//线程安全模式
class SingletonTest03 {

    private static volatile SingletonTest03 instance;

    private SingletonTest03() {
    }

    public static SingletonTest03 getInstance() {
        if (instance == null) {
            synchronized (SingletonTest03.class) {
                if (instance == null) {
                    instance = new SingletonTest03();
                }

            }
        }
        return instance;
    }


}